From 21062fab022b97fb37d9ffa29eae7f3815ef6a16 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 25 Jul 2017 15:46:01 +0200 Subject: [PATCH] gtklinkbutton: Set cursor on button's event window It is not necessary to (re)set the cursor on every crossing event, and can probably yield the wrong results if there are multiple master devices involved. Just set it on init(), and let the inner machinery update the cursor whenever necessary. This patch is an adaption of commit 0daf79676 in gtk-3-22, the side effects are not as bad here because the cursor was already being set on the widget specifically instead of the parent widget's, but there's still some nonetheless (plus, it's simpler) https://bugzilla.gnome.org/show_bug.cgi?id=785375 --- gtk/gtklinkbutton.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c index 8c42330930..37aaf10107 100644 --- a/gtk/gtklinkbutton.c +++ b/gtk/gtklinkbutton.c @@ -106,12 +106,6 @@ static void gtk_link_button_set_property (GObject *object, GParamSpec *pspec); static void gtk_link_button_clicked (GtkButton *button); static gboolean gtk_link_button_popup_menu (GtkWidget *widget); -static gboolean gtk_link_button_enter_cb (GtkWidget *widget, - GdkEventCrossing *event, - gpointer user_data); -static gboolean gtk_link_button_leave_cb (GtkWidget *widget, - GdkEventCrossing *event, - gpointer user_data); static void gtk_link_button_drag_data_get_cb (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection, @@ -132,6 +126,9 @@ static void gtk_link_button_pressed_cb (GtkGestureMultiPress *gesture, static gboolean gtk_link_button_activate_link (GtkLinkButton *link_button); +static void set_hand_cursor (GtkWidget *widget, + gboolean show_hand); + static const GtkTargetEntry link_drop_types[] = { { (char *) "text/uri-list", 0, 0 }, { (char *) "_NETSCAPE_URL", 0, 0 } @@ -227,10 +224,6 @@ gtk_link_button_init (GtkLinkButton *link_button) gtk_button_set_relief (GTK_BUTTON (link_button), GTK_RELIEF_NONE); gtk_widget_set_state_flags (GTK_WIDGET (link_button), GTK_STATE_FLAG_LINK, FALSE); - g_signal_connect (link_button, "enter-notify-event", - G_CALLBACK (gtk_link_button_enter_cb), NULL); - g_signal_connect (link_button, "leave-notify-event", - G_CALLBACK (gtk_link_button_leave_cb), NULL); g_signal_connect (link_button, "drag-data-get", G_CALLBACK (gtk_link_button_drag_data_get_cb), NULL); @@ -253,6 +246,8 @@ gtk_link_button_init (GtkLinkButton *link_button) context = gtk_widget_get_style_context (GTK_WIDGET (link_button)); gtk_style_context_add_class (context, "link"); + + set_hand_cursor (GTK_WIDGET (link_button), TRUE); } static void @@ -459,26 +454,6 @@ gtk_link_button_popup_menu (GtkWidget *widget) return TRUE; } -static gboolean -gtk_link_button_enter_cb (GtkWidget *widget, - GdkEventCrossing *crossing, - gpointer user_data) -{ - set_hand_cursor (widget, TRUE); - - return FALSE; -} - -static gboolean -gtk_link_button_leave_cb (GtkWidget *widget, - GdkEventCrossing *crossing, - gpointer user_data) -{ - set_hand_cursor (widget, FALSE); - - return FALSE; -} - static void gtk_link_button_drag_data_get_cb (GtkWidget *widget, GdkDragContext *context, -- 2.30.2